// 存储
export const SET_CACHE = (key: string, value: any) => {
  localStorage.setItem(
    key,
    typeof value === "string" ? value : JSON.stringify(value)
  );
};

// 获取
export const GET_CACHE = (key: string) => {
  try {
    const value = localStorage.getItem(key);
    if (value === null || value === undefined || value === "") {
      return null;
    }
    return JSON.parse(localStorage.getItem(key) as string);
  } catch (e) {
    return null;
  }
};

// 删除
export const REMOVE_CACHE = (type: string) => {
  localStorage.removeItem(type);
};
